/*************************************************************************
 *                                                                       *
 * This file is part of the DogosFrame distribution.  For full copyright *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 *                                                                       *
 *************************************************************************/

#ifndef DOGOS_HAVE_MPI
inline
DOGOS_MPI::Status::Status():
    MPI_SOURCE (-1),
    MPI_TAG    (-1),
    MPI_ERROR  (-1)
{}
#endif


inline const DOGOS_MPI&
DOGOS_MPI::get_MPI_world()
{
    return s_mpi_world;
}


inline
DOGOS_MPI::DOGOS_MPI(const Comm& comm):
    d_comm (comm),
    d_rank (-1),
    d_size (-1)
{
#ifdef DOGOS_HAVE_MPI
    if (comm != MPI_COMM_NULL)
    {
        if (s_mpi_is_initialized)
        {
            MPI_Comm_rank (d_comm, &d_rank);
            MPI_Comm_size (d_comm, &d_size);
        }
    }
    else
    {
        d_rank = 0;
        d_size = 1;
    }
#else
    d_rank = 0;
    d_size = 1;
#endif
}


inline int
DOGOS_MPI::get_rank() const
{
    return d_rank;
}


inline
int DOGOS_MPI::size() const
{
    return d_size;
}


inline
const DOGOS_MPI::Comm& DOGOS_MPI::get_communicator() const
{
    return d_comm;
}
